package org.cytoscape.myapp.cytoscape_app_v1.internal.model;

import java.util.HashMap;
import java.util.Map;

import org.cytoscape.application.CyApplicationManager;
import org.cytoscape.group.CyGroupFactory;
import org.cytoscape.group.CyGroupManager;
import org.cytoscape.model.CyNetwork;
import org.cytoscape.myapp.cytoscape_app_v1.internal.layouts.KKLayout.algorithms.KKNodeLayout;
import org.cytoscape.myapp.cytoscape_app_v1.internal.visual.VisualInstanceDependecies;

public class NetworkManager implements UtilNetworkManager {
	
	protected CyApplicationManager applicationManager;
	protected CyGroupManager groupManager;
	protected CyGroupFactory groupFactory;
	protected Map<Long, NetworkSettings> networkSettings;
	protected VisualInstanceDependecies visualInstanceDependecies;
	protected KKNodeLayout kkNodeLayout;
	
	
	public NetworkManager(CyApplicationManager applicationManager,
			CyGroupManager groupManager, CyGroupFactory groupFactory, VisualInstanceDependecies visualInstanceDependecies, KKNodeLayout kkNodeLayout) {
		super();
		this.applicationManager = applicationManager;
		this.groupManager = groupManager;
		this.groupFactory = groupFactory;
		this.networkSettings = new HashMap<Long, NetworkSettings>();
		this.visualInstanceDependecies = visualInstanceDependecies;
		this.kkNodeLayout = kkNodeLayout;
	}

	public NetworkSettings getCurrrentNetworkSettings(CyNetwork cyNetwork) {
	
		return this.networkSettings.get(cyNetwork.getSUID());
	}

	public void addNetworkSettings(CyNetwork cyNetwork) {
	
		if (!this.networkSettings.containsKey(cyNetwork.getSUID()))
			this.networkSettings.put(cyNetwork.getSUID(),
					new NetworkSettings(applicationManager, groupManager, groupFactory, visualInstanceDependecies, kkNodeLayout));
	}


	public NetworkSettings getCurrrentNetworkSettings(Long suid) {
		
		return this.networkSettings.get(suid);
	}

	
	public boolean existsNetworkSettings(Long suid) {
		if (!this.networkSettings.containsKey(suid))
			return false;
		return true;
	}
}
